// Model factory definition
// Copyright 2004 (C) Ralph Thomas

#ifndef MODEL_FACTORY_H
#define MODEL_FACTORY_H

#include <model/model.h>
#include <model/internal/url.h>

namespace model {
	//
	/// The factory class is implemented by DSOs which have a model
	/// that can be loaded out of them. It allows the model to be
	/// created, and when all the models made by this factory are
	/// done, the factory is released.
	//
	class factory {
	  public:
		//
		// model* fromString( util::string serialized ) const
		//
		/// Create a model from the serialized model or URL.
		///
		/// \return	either a new model, or NULL if no model could
		///		be made (by this factory) from the given string.
		//
		virtual model* fromString( util::string serialized ) const = 0;
		//
		// url* normalize( const url* theUrl ) const
		//
		/// Normalizing a URL means that the URL might be changed so
		/// that any two URLs pointing to the same resource are the
		/// same after normalization. This operation is performed to
		/// ensure that only one instance of a model exists per
		/// resource. Typically this only serves as an optimization
		/// (as a model may only represent the state of something
		/// else, and may not have state of it's own).
		///
		/// \param	theUrl	the URL to normalize
		/// \return	the normalized URL, or NULL if the given URL
		///		cannot be used by this factory.
		//
		virtual url* normalize( const url* theUrl ) const = 0;
	};
};

#endif

